//引入一级路由
// import Home from '@/pages/home';
// import Search from '@/pages/search';
// import Login from '@/pages/login';
// import Register from '@/pages/register';
// import Detail from '@/pages/detail';
// import AddCartSuccess from '@/pages/addCartSuccess';
// import ShopCart from '@/pages/shopCart';
// import Trade from '@/pages/trade'
// import Pay from '@/pages/Pay';
// import PaySuccess from '@/pages/PaySuccess';
// import Center from '@/pages/Center';
// import MyOrder from '@/pages//Center/myorder';
// import TeamOrder from '@/pages/Center/teamorder';



//对外暴露路由配置数据
export default[
  {
    path:'/home',//路径名字都是小写的
    component:()=>import('@/pages/home'),
    meta:{isShow:true},
  },
  {
    path:'/search/:keyword?',
    component: ()=>import('@/pages/search'),
    meta:{isShow:true},
    name:'search',
    // props:true,
    // props:{a:1,b:2,c:'haode'}
    // props:route=>({a:1,b:2,c:'hhhh',path:route.path,meta:route.meta})
  },
  {
    path:'/login',
    component:()=>import('@/pages/login'),
    meta:{isShow:false},
  },
  {
    path:'/register',
    component:()=>import('@/pages/register'),
    meta:{isShow:false},
  },
  {
    path:'/',
    redirect:'/home',
  },
   {
    path:'/detail/:skuId',
    component:()=>import('@/pages/detail'),
    meta:{isShow:true},
   },
   {
    // 加入购物车成功页面,params携带商品数量
    path:'/addcartsuccess/:skuNum',
    name:'addcartsuccess',
    component:()=>import('@/pages/addCartSuccess'),
    meta:{
        isShow:true
    }
   },
   {
    path:'/shopcart',
    component:()=>import('@/pages/shopCart'),
    meta:{
      isShow:true
    }
   },
   {
    path:'/trade',
    component:()=>import('@/pages/trade'),
    meta:{
      isShow:true
    },
    //路由独享守卫 交易页面
    beforeEnter:(to,from,next)=>{
      if(from.path=='/shopcart'){
        next();
      }else{
        next(false)
      }
    }
   },
   {
    path:'/pay',
    component:()=>import('@/pages/Pay'),
    meta:{
      isShow:true
    },
    beforeEnter:(to,from,next)=>{
      //交易页守卫:如果你是从购物车而来,可以进入交易页
      if(from.path=='/trade'){
        next()
      }else{
        next(false)
      }
    }
   },
   {
    path:'/paysuccess',
    component:()=>import('@/pages/PaySuccess'),
    meta:{
      isShow:true
    }
   },
   {
    path:'/center',
    component:()=>import('@/pages/Center'),
    meta:{
      isShow:true
    },
    //二级路由组件配置
    children:[
      {
          path:'myorder', //两种写法:全称书写 /center/myorder  myorder 
          component:()=>import('@/pages/Center/myorder'),
      },
      {
          path:'teamorder',
          component:()=>import('@/pages/Center/teamorder'),
      },
      {
          path:'/center',
          redirect:'/center/myorder'
      }
 ]
   }
 ]